home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Essentials / Developer Essentials Nov 90 / Apple II / Apple.II.partition / Utilities / rTutors / part3.2 / rTutor.rez < prev    next >
Encoding:
Text File  |  1990-06-19  |  14.7 KB  |  520 lines  |  [TEXT/pdos]

  1. /* File: Rtutor.Rez */
  2. /* Rez source file for C version of resource tutorial */
  3. /* Part 1:  starting up & shutting down the tools using a resource */
  4. /* Part 2:  do Part 1 and insert a menubar with menus */
  5. /* Part 2.5:  do part 2 and add an event loop so app stays up */
  6. /* Part 3:  do part 2.5 and add a window (w/ controls) from a resource */
  7. /* Part 3.2: do part 3 & replace About box with AlertWindow (from resource) */
  8.  
  9. /* this gives use access to the "standard" pre-defined resource types */
  10. #include "Types.rez"
  11.  
  12. /*---------------------- Startup Record ---------------------------*/
  13. resource rToolStartup (1)
  14. {
  15.  $C080,       /* set master SCB to mode640 + fFastPortAware + fUseShadowing */
  16.  {
  17.   3,$0300,      /* misc tools */
  18.   4,$0302,      /* quickdraw */
  19.   5,$0302,      /* desk manager */
  20.   6,$0300,      /* eventMgr */
  21. /*  7,$0300,      /* scheduler */ /* not used by apps or DA's */
  22. /*  8,$0301,      /* sound tools */ /* not used by this app */
  23. /*  9,$0300,      /* ADB tools */ /* not used by this app */
  24. /*  10,$0300,      /* SANE */ /* started already by pStart.obj */
  25.   11,$0300,      /* int math */
  26.   14,$0301,      /* Window Manager */
  27.   15,$0301,      /* Menu Manager */
  28.   16,$0300,      /* Control Manager */
  29.   18,$0301,      /* QD Aux */
  30.   19,$0300,      /* print manager */
  31.   20,$0301,      /* LineEdit tool set */
  32.   21,$0302,      /* Dialog Manager */
  33.   22,$0300,      /* Scrap manager */
  34.   23,$0301,      /* standard file */
  35.   27,$0301,      /* Font manager */
  36.   28,$0301,      /* list manager */
  37.   34,$0101,      /* text edit */
  38. /*  29,$0100,      /* ACE */ /* not used by this app */
  39. /*  32,$0100,      /* Midi Tools */ /* not used by this app */
  40. /*  25,$0100,      /* NoteSynth */ /* not used by this app */
  41. /*  26,$0100      /* Note Seq */ /* not used by this app */
  42.  }
  43. };
  44.  
  45.  
  46. /*---------------------- Menus & Menu Bars ---------------------------*/
  47.     /* define the resource id of the menu bar itself */
  48. #define    kMenuBarID1       1
  49.  
  50.     /* define all the menu id's */
  51. #define    kAppleMID   1000
  52. #define    kFileMID    2000
  53. #define    kEditMID    3000
  54.  
  55.     /* now, define the menu item id's */
  56. #define    kAboutBoxIID    1001 /* the "About..." box */
  57.     
  58. #define    kNewItem        2001 /* the "New" item */
  59. #define    kOpenItem       2002 /* the "Open..." item */
  60. #define    kCloseItem       255 /* the "Close" item */
  61. #define    kSaveItem       2004 /* the "Save" item */
  62. #define    kSaveAsItem     2005 /* the "Save As..." item */
  63. #define    kQuitItem       2009 /* the "Quit" item */
  64.       
  65. #define    kUndoItem        250 /* the "Undo" item */
  66. #define    kCutItem         251 /* the "Cut" item */
  67. #define    kCopyItem        252 /* the "Copy" item */
  68. #define    kPasteItem       253 /* the "Paste" item */
  69. #define    kClearItem       254 /* the "Clear" item */
  70. #define    kSelectItem     3001 /* the "Select All" item */
  71. #define    kShowClipItem   3002 /* the "Show Clipboard" item */
  72.       
  73.     /* now, define the menu bar */
  74. resource rMenuBar (kMenuBarID1)
  75. {
  76.     {
  77.         kAppleMID,
  78.         kFileMID,
  79.         kEditMID,
  80.     };
  81. };
  82.  
  83.  
  84. /* lay out the Apple menu */
  85. /* this takes several steps: */
  86. /* 1)  define the menu itself in a resource of type "rMenu" */
  87. /* 2)  define the rPString that will be used for the name of the menu */
  88. /* 3)  define the first item in the menu in a resource of type "rMenuItem" */
  89. /* 4)  define the rPString that will be used for the name of the first item */
  90. /* 5)  repeat steps 3 and 4 for all remaining items in that menu */
  91. /* 6)  repeat steps 1 through 5 for all remaining menus */
  92.     
  93. resource rMenu (kAppleMID, nocrossbank)
  94. {
  95.     kAppleMID,    /* ID of the menu this item belongs to */
  96.     0xA008, /* flags => menu title is a resource, items are resources, menu */
  97.             /* is enabled, XOR highlighting, std menu, caching ok */
  98.     kAppleMID,    /* ref to menu's title */
  99.     { kAboutBoxIID }; /* array of items in this menu (only 1 to start with) */
  100. };
  101.  
  102. resource rPString (kAppleMID, nocrossbank)
  103. {
  104.     "@"                    /* this string is the title of the "Apple" menu */
  105. };
  106.  
  107. /* see IIGS Toolbox Reference, Volume 3, menu item template */
  108. resource rMenuItem (kAboutBoxIID, nocrossbank)
  109. {
  110.     kAboutBoxIID, /* item's ID */
  111.     "",           /* no keyboard equivalent */
  112.     "",           /* no keyboard equivalent (allowed 2, this is the 2nd) */
  113.     0,            /* this item does not have a check mark by it */
  114.     0x8040,       /* title is in a resource, enabled (bit 7=0), */
  115.                   /* dividing line below (bit 6=1)  */
  116.     kAboutBoxIID  /* ref of the item's title */
  117. };
  118.  
  119. resource rPString (kAboutBoxIID, nocrossbank)
  120. {
  121.     "About rTutor" /* used as the title for the "About..." item */
  122. };
  123.  
  124.  
  125.     /* lay out the File menu */
  126.     
  127. resource rMenu (kFileMID, nocrossbank)
  128. {
  129.     kFileMID,  /* ID of the menu this item belongs to */
  130.     0xA008,    /* flags => menu title is a resource, items are resources, */
  131.                /* menu is enabled, don't use XOR highlighting, std menu,  */
  132.                /* caching ok */
  133.     kFileMID,  /* ref to menu's title */
  134.     {          /* array of items in this menu */
  135.         kNewItem,
  136.         kOpenItem,
  137.         kCloseItem,
  138.         kSaveItem,
  139.         kSaveAsItem,
  140.         kQuitItem
  141.     };
  142. };
  143.  
  144. resource rPString (kFileMID, nocrossbank)
  145. {
  146.     " File "   /* this string is the title of the "File" menu */
  147. };
  148.  
  149. resource rMenuItem (kNewItem, nocrossbank)
  150. {
  151.     kNewItem,  /* item's ID */
  152.     "N",       /* keyboard equivalent = "N" */
  153.     "n",       /* or = "n" (either key will work) */
  154.     0,         /* this item does not have a check mark by it */
  155.     0x8000,    /* title is in a resource, enabled (bit 7 = 0)  */
  156.     kNewItem   /* ref of the item's title */
  157. };
  158.  
  159. resource rPString (kNewItem, nocrossbank)
  160. {
  161.     "New"      /* this string is used as the title for the "New" item */
  162. };
  163.  
  164. resource rMenuItem (kOpenItem, nocrossbank)
  165. {
  166.     kOpenItem,
  167.     "O",       /* that's an "OH" on this line, not a "zero" */
  168.     "o",       /* that's an "OH" on this line, not a "zero" */
  169.     0,         /* this one's a "zero" */
  170.     0x8040,    /* the "4" means put a dividing line under this item */
  171.     kOpenItem
  172. };
  173.  
  174. resource rPString (kOpenItem, nocrossbank)
  175. {
  176.     "Open..."
  177. };
  178.  
  179. resource rMenuItem (kCloseItem, nocrossbank)
  180. {
  181.     kCloseItem,
  182.     "W",
  183.     "w",
  184.     0,
  185.     0x8000,
  186.     kCloseItem
  187. };
  188.  
  189. resource rPString (kCloseItem, nocrossbank)
  190. {
  191.     "Close"
  192. };
  193.  
  194. resource rMenuItem (kSaveItem, nocrossbank)
  195. {
  196.     kSaveItem,
  197.     "S",
  198.     "s",
  199.     0,
  200.     0x8000,
  201.     kSaveItem
  202. };
  203.  
  204. resource rPString (kSaveItem, nocrossbank)
  205. {
  206.     "Save"
  207. };
  208.  
  209. resource rMenuItem (kSaveAsItem, nocrossbank)
  210. {
  211.     kSaveAsItem,
  212.     "",        /* no key equivalents for this item */
  213.     "",
  214.     0,
  215.     0x8000,
  216.     kSaveAsItem    
  217. };
  218.  
  219. resource rPString (kSaveAsItem, nocrossbank)
  220. {
  221.     "Save As..."
  222. };
  223.  
  224. resource rMenuItem (kQuitItem, nocrossbank)
  225. {
  226.     kQuitItem,
  227.     "Q",
  228.     "q",
  229.     0,
  230.     0x8000,
  231.     kQuitItem    
  232. };
  233.  
  234. resource rPString (kQuitItem, nocrossbank)
  235. {
  236.     "Quit"
  237. };
  238.  
  239.  
  240.     /* lay out the Edit menu */
  241.     
  242. resource rMenu (kEditMID, nocrossbank)
  243. {
  244.     kEditMID,    /* ID of the menu this item belongs to */
  245.     0xA008,
  246.     kEditMID,    /* ref to menu's title */
  247.     {            /* array of items in this menu */
  248.         kUndoItem,
  249.         kCutItem,
  250.         kCopyItem,
  251.         kPasteItem,
  252.         kClearItem,
  253.         kSelectItem,
  254.         kShowClipItem
  255.     };
  256. };
  257.  
  258. resource rPString (kEditMID, nocrossbank)
  259. {
  260.     " Edit "   /* this string is the title of the "Edit" menu */
  261. };
  262.  
  263. resource rMenuItem (kUndoItem, nocrossbank)
  264. {
  265.     kUndoItem,
  266.     "Z",
  267.     "z",
  268.     0,
  269.     0x8040,
  270.     kUndoItem
  271. };
  272.  
  273. resource rPString (kUndoItem, nocrossbank)
  274. {
  275.     "Undo"
  276. };
  277.  
  278. resource rMenuItem (kCutItem, nocrossbank)
  279. {
  280.     kCutItem,
  281.     "X",
  282.     "x",
  283.     0,
  284.     0x8000,
  285.     kCutItem
  286. };
  287.  
  288. resource rPString (kCutItem, nocrossbank)
  289. {
  290.     "Cut"
  291. };
  292.  
  293. resource rMenuItem (kCopyItem, nocrossbank)
  294. {
  295.     kCopyItem,
  296.     "C",
  297.     "c",
  298.     0,
  299.     0x8000,
  300.     kCopyItem
  301. };
  302.  
  303. resource rPString (kCopyItem, nocrossbank)
  304. {
  305.     "Copy"
  306. };
  307.  
  308. resource rMenuItem (kPasteItem, nocrossbank)
  309. {
  310.     kPasteItem,
  311.     "V",
  312.     "v",
  313.     0,
  314.     0x8000,
  315.     kPasteItem
  316. };
  317.  
  318. resource rPString (kPasteItem, nocrossbank)
  319. {
  320.     "Paste"
  321. };
  322.  
  323. resource rMenuItem (kClearItem, nocrossbank)
  324. {
  325.     kClearItem,
  326.     "",
  327.     "",
  328.     0,
  329.     0x8000,
  330.     kClearItem
  331. };
  332.  
  333. resource rPString (kClearItem, nocrossbank)
  334. {
  335.     "Clear"
  336. };
  337.  
  338. resource rMenuItem (kSelectItem, nocrossbank)
  339. {
  340.     kSelectItem,
  341.     "A",
  342.     "a",
  343.     0,
  344.     0x8040,  /* the "4" means this one has a divider under it */
  345.     kSelectItem
  346. };
  347.  
  348. resource rPString (kSelectItem, nocrossbank)
  349. {
  350.     "Select All"
  351. };
  352.  
  353. resource rMenuItem (kShowClipItem, nocrossbank)
  354. {
  355.     kShowClipItem,
  356.     "",
  357.     "",
  358.     0,
  359.     0x8000,
  360.     kShowClipItem
  361. };
  362.  
  363. resource rPString (kShowClipItem, nocrossbank)
  364. {
  365.     "Show Clipboard"
  366. };
  367.  
  368.  
  369. /*---------------------- Windows and their contents --------------------------*/
  370.     /* define the resource ID's for all windows used by this app */
  371. #define myWindowID    2362  /* window's resource ID = 2362 */
  372.  
  373. /* First, we lay out the window itself */
  374. resource rWindParam1 (myWindowID) 
  375. {
  376.  fTitle+fMove+fVis, /* has a title, can be moved, and it is visible */
  377.  myWindowID,         /* resource ID of the title */
  378.  0,                 /* no ref Con needed */
  379.  {0,0,0,0},         /* no zoom box, so we don't care about the zoom rect */
  380.  0,                 /* use std color table for now */
  381.  {0,0},             /* upper left corner of vis rgn = upper left of document */
  382.  {0,0},             /* we don't really have a "document" for this window, so */
  383.                     /* set the data size to zero */
  384.  {0,0},             /* maximum height and width */
  385.  {0,0},             /* don't scroll vertically or horizontally */
  386.  {0,0},             /* no "document", so page size is zero also */
  387.  0,                 /* passed to info bar draw routine - not used here */
  388.  0,                 /* height of info bar - not used here */
  389.  {46,100,176,540},  /* this rect defines the boundaries of the window */
  390.  infront,           /* window comes up in front of other windows */
  391.  0,                 /* set to NIL to avoid bug in NewWindow2 */
  392.  refIsResource*0x0100+resourceToResource /* title string and */
  393.                                          /* control list are resources */
  394. };
  395.  
  396. /* define the title string used by our window */
  397. resource rPstring (myWindowID)
  398. {
  399.     " This came from a resource "
  400. };
  401.  
  402.  
  403. /* define the list of controls that are in the default window */
  404. /* we're taking it easy for now and are putting in only: */
  405. /* a simple round button and a text edit field */
  406. /* so, we need to define the constants used by those controls */
  407.  
  408. #define myRoundButton    $0001
  409. #define myTEField       $0002
  410.  
  411. resource rControlList (myWindowID) 
  412. {
  413.  {
  414.  myRoundButton,
  415.  myTEField,
  416.  };
  417.   /* last item in a control list HAS to be NIL, but the template for a */
  418.   /* rControlList takes care of sticking the NIL in there for us!  */
  419. };
  420.  
  421. /* define the simple round button */
  422. resource rControlTemplate (myRoundButton) 
  423. {
  424.  myRoundButton, /* ID of this control */
  425.  {8,152, 22, 290}, /* boundary rect for button  */
  426.  SimpleButtonControl    /* type of control */
  427.  {
  428.   { 
  429.    0, /* button is visible and has simple rounded corners */
  430.    0x1002, /* bit 12 MUST be set!!! and title is in a resource */
  431.    0, /* ignore the ref con */
  432.    myRoundButton /* resource ID of title string */
  433.   }
  434.  };
  435. };
  436.  
  437. /* define the title string used by the simple button */
  438. resource rpString (myRoundButton) 
  439. {
  440.  "Rent this space"
  441. };
  442.  
  443. /* define the text edit field */
  444. resource rControlTemplate (myTEField) 
  445. {
  446.   myTEField, /* ID of the text edit control */
  447.  {30,10,120,430}, /* bounding rectangle for the text edit field */
  448.  EditTextControl    /* type of control */
  449.  {
  450.   { 
  451.     0x0000, /* field is visible ("flag" field") */
  452.     0x7400, /* see Toolbox Ref, volume 3 for details */
  453.     0, /* ignore the ref con */
  454.     0x42A80000, /* text flags - see Toolbox Ref, volume 3 */
  455.     {$FFFF,$FFFF,$FFFF,$FFFF}, /* use std values for indent rect */
  456.     $FFFFFFFF, /* allow vertical scroll bar */
  457.     0, /* use default vertical scroll amount */
  458.     0, /* horzBar - MUST be NIL */
  459.     0, /* horzAmount - MUST be zero */
  460.     0, /* use default style and ruler info */
  461.     dataIsPString+RefIsResource*8, /* default text is in a rPstring resource */
  462.     myTEField, /* resource ID of default text */
  463.     0 /* text length - set by toolbox when text resource is read in */
  464.   }
  465.  };
  466. }; 
  467.  
  468. /* define the text that will show up when the text edit field is created */
  469. resource rPString (myTEField) 
  470. {
  471. "Try selecting this text, then pick COPY, CUT, and/or PASTE from the EDIT menu."
  472. };
  473.  
  474. /*--------- Alert Window - used as our About Box --------------------*/
  475.  
  476. #define kAboutStr    100    /* define the constant for the About box's string */
  477.  
  478. resource rAlertString (kAboutStr) 
  479. {
  480.  "\$30"                 /* we're using a custom sized box */
  481.  "\$1E\$00"             /* top coord (v1) for custom sized box */
  482.  "\$AA\$00"             /* left coord (h1) for custom sized box */
  483.  "\$B0\$00"             /* bottom coord (v2) for custom sized box */
  484.  "\$D6\$01"             /* right coord for (h2) custom sized box */
  485.  "\$30"                 /* no icon in the window */
  486.  "/"                    /* seperator character */
  487.  TBEndOfLine            /* stick an extra blank line in there */
  488.  TBEndOfLine            /* stick an extra blank line in there */
  489.  TBCenterJust           /* center the text */
  490.  TBStyleBold            /* turn on bold face */
  491.  "rTutor.S16"           /* the first line of text */
  492.  TBEndOfLine            /* mark the end of the line */
  493.  TBEndOfLine            /* stick an extra blank line in there */
  494.  TBStylePlain           /* turn off bold face */
  495.  "The Rez tutorial application"    /* the next line of text */
  496.  TBEndOfLine            /* mark the end of the line */
  497.  TBEndOfLine            /* stick an extra blank line in there */
  498.  TBStylePlain           /* turn off italics */
  499.  TBForeColor            /* set foreground color to... */
  500.  TBColor0               /* ...black */
  501.  "written by:"          /* another line of text */
  502.  TBEndOfLine            /* mark the end of the line */
  503.  TBEndOfLine            /* stick an extra blank line in there */
  504.  TBForeColor            /* set foreground color to... */
  505.  TBColor1               /* ...red */
  506.  "Tim Swihart"          /* the name of this app's author */
  507.  TBEndOfLine            /* mark the end of the line */
  508.  TBEndOfLine            /* stick an extra blank line in there */
  509.  TBEndOfLine            /* stick an extra blank line in there */
  510.  TBStylePlain           /* turn off bold face */
  511.  TBForeColor            /* set foreground color to... */
  512.  TBColor0               /* ...black */
  513.  "Version 3.2"          /* last line of text */
  514.  "/"                    /* "/" is our seperator character */
  515.  "^Thanks, Tim!"     /* "^" means make the button the "default" (tie it to */
  516.                /* the RETURN key) - make the button's text be "Thanks, Tim!" */
  517.  "\$00"        /* make sure the string is NULL terminated since we told */
  518.                /* the window manager we would be using a C string */
  519. };
  520.